package com.yiboshi.rehrs.config;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author jack 2022/9/20
 */
@Component
public final class RehrsSystemConfig {

    static Logger logger = LoggerFactory.getLogger(RehrsSystemConfig.class);
    private static String profile;

    private static int serverPort;

    private static String serverIp;

    @Getter
    private static String applicationName;

    @Getter
    @Setter
    private static String swaggerKey = "2142398573452954";

    public static boolean isDev() {
        return "dev".equals(profile);
        //return false;
    }

    public static boolean isTest() {
        return isDev()||"yibobeta".equals(profile)||"test".equals(profile);
    }


    public static void setApplicationName(String applicationName) {
        RehrsSystemConfig.applicationName = applicationName;
    }


    public static String getServerIpAndPort() {
        if (StrUtil.isEmpty(serverIp)) {
            logger.error("data not load");
            return "";
        }
        return serverIp + ":" + serverPort;
    }


    public static String getProfile() {
        return profile;
    }

    public static void setProfile(String profile) {
        RehrsSystemConfig.profile = profile;
    }

    public static int getServerPort() {
        return serverPort;
    }

    public static void setServerPort(int serverPort) {
        RehrsSystemConfig.serverPort = serverPort;
    }

    public static String getServerIp() {
        return serverIp;
    }

    public static void setServerIp(String serverIp) {
        RehrsSystemConfig.serverIp = serverIp;
    }
}
